<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
      
      
<ui:composition template="/template.xhtml">
	<ui:define name="content">
		<p:layoutUnit position="north" resizable="false" closable="false" collapsible="false" size="200" style="border: none;">
			<p:layout>
				<div align="center">
					<!-- LOGO -->
					<p:layoutUnit id="layoutLogo" position="west" size="16%">
						<p:graphicImage value="/images/logo.jpg" />
					</p:layoutUnit>

					<!-- CABECALHO -->
					<p:layoutUnit id="layoutCabecalho" position="center">
						<h:form>
							<p:outputLabel id="textCabecalho" value="#{cabecalhoBean.cabecalho.conteudo}" escape="false" />
							<p:commandButton id="btnEditarCab" type="button" value="Alterar" onclick="dialogEditarCabecalho.show()" icon="ui-icon-pencil" />
						</h:form>
					</p:layoutUnit>
				</div>
			</p:layout>
		</p:layoutUnit>
		
		<!-- MENU -->
		<p:layoutUnit position="west" resizable="false" closable="false" collapsible="false" size="16%">  
			<div align="center">
				<h:form>
					<p:menu >  
				        <p:submenu label="Aluno">  
				            <p:menuitem value="Cadastrar" action="#{cadastroBean.avancarCadastroInicio}" icon="ui-icon-plusthick" ajax="false"/>  
				        </p:submenu>  
				        <p:submenu label="Backup">  
				            <p:menuitem value="Download" icon="ui-icon-circle-arrow-s" ajax="false" oncomplete="#{cadastroBean.apagarArquivo}">
				            	<p:fileDownload value="#{cadastroBean.arquivoDownload}" /> 
				            </p:menuitem>  
				        </p:submenu>  
				    </p:menu>
				</h:form>
			</div>
	   	</p:layoutUnit>  
		  
		<p:layoutUnit position="center"> 
			<h:form>
				<!-- PESQUISA -->
				<p:panel header="Área de Pesquisa">
					<p:panelGrid columns="2" id="painel">
						<h:outputLabel for="matricula-filter" value="Matrícula: " />
						<p:inputText id="matricula-filter" value="#{cadastroBean.matricula}" size="10" />
		
						<h:outputLabel for="nome-filter" value="Nome: " />
						<p:inputText id="nome-filter" value="#{cadastroBean.nome}" size="50" />
						
						<h:inputHidden />
						<p:commandButton actionListener="#{cadastroBean.pesquisarAluno()}" value="Pesquisar" icon="ui-icon-search"  update="@([id$=dataTableBusca])" />
					</p:panelGrid>
				</p:panel>
		
				<!-- RESULTADO -->
				<p:panel header="Resultado">
					<p:dataTable id="dataTableBusca" paginator="true" rows="5" var="aluno" value="#{cadastroBean.listaAlunos}"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15">
		
						<p:column headerText="Matricula" width="20%">
							<h:outputText value="#{aluno.matricula}" />
						</p:column>
		
						<p:column headerText="Nome">
							<h:outputText value="#{aluno.nome}" />
						</p:column>
		
						<p:column headerText="Editar" width="10%">
							<div align="center">
								<p:commandButton action="#{cadastroBean.editarAluno(aluno)}" icon="ui-icon-pencil" />
							</div>
						</p:column>
		
						<p:column headerText="Excluir" width="10%">
							<div align="center">
								<p:commandButton actionListener="#{cadastroBean.excluirAluno(aluno)}" icon="ui-icon-trash" update="@([id$=dataTableBusca, messages])"
										onclick="if (!confirm('Você deseja remover o item selecionado?')) return false;"/>
							</div>
						</p:column>
		
						<p:column headerText="Imprimir" width="10%">
							<div align="center">
								<p:commandButton actionListener="#{cadastroBean.selecionarAlunoImpressao(aluno)}" icon="ui-icon-print"  
										oncomplete="dialogImprimirAluno.show();" />
							</div>
						</p:column>
						
					</p:dataTable>
				</p:panel>
			</h:form>
	</p:layoutUnit>
	
	<!--  DIALOG EDITAR CABEÇALHO -->
	<p:dialog widgetVar="dialogEditarCabecalho" modal="true" header="Editar Cabeçalho" width="auto" styleClass="fundoDialog" 
			showEffect="fade" hideEffect="fade" resizable="false" id="editarCabecalhoDialog">
	
		<h:form>
			<p:editor id="editorId" widgetVar="editor" value="#{cabecalhoBean.cabecalho.conteudo}" width="500"
				controls="bold italic underline font size color alignleft center alignright justify undo redo cut copy paste"/>
				
			<p:separator />
			<p:commandButton onclick="dialogEditarCabecalho.hide()" value="Cancelar" icon="ui-icon-close"/>
			<p:commandButton action="#{cabecalhoBean.salvar()}" value="Salvar" icon="ui-icon-disk" onsuccess="dialogEditarCabecalho.hide()" ajax="false" update="@([id$=textCabecalho])"/>
		</h:form>
		
	</p:dialog>
	
	<!-- DIALOG IMPRIMIR ALUNO -->
	<p:dialog widgetVar="dialogImprimirAluno" modal="true" header="Imprimir Aluno" width="40%" styleClass="fundoDialog"
			showEffect="fade" hideEffect="fade" resizable="false" id="imprimirAlunoDialog">
		
		<h:form id="formImprimir">
			<h:panelGrid border="0" style="margin-bottom:10px" cellpadding="5" columns="2">
				<p:outputLabel value="Adicionar cabeçalho à impressão?" />
				<p:selectBooleanButton value="#{cadastroBean.adicionarCabecalho}" onLabel="Sim" offLabel="Não" />
			</h:panelGrid>
	
			<p:separator />
			<p:commandButton onclick="dialogImprimirAluno.hide()" value="Cancelar"  icon="ui-icon-close" />
			<p:commandButton action="imprimir" value="Imprimir" icon="ui-icon-print" onsuccess="dialogImprimirAluno.hide()" ajax="false"/>
		</h:form>
	</p:dialog>
	
	</ui:define>
</ui:composition>
</html>